<template>
  <div class="wrap pd20">
    <el-form label-position="top" ref="form" :model="form" :rules="rules" class="form">
      <el-form-item :label="$t('configLazyLoad.channel.globalTip4')">
        <el-radio-group v-model.trim="shareScreen">
          <el-radio  label="1">{{$t('public.yes')}}</el-radio>
          <el-radio  label="0">{{$t('public.no')}}</el-radio>
        </el-radio-group>
      </el-form-item>
      <!--<span class="help-tips">默认值为否,启用优劣会话自动判断,系统将自动判断会话是优质会话还是劣质会话</span>-->
      <el-form-item :label="$t('configLazyLoad.channel.globalTip5')">
        <el-radio-group v-model.trim="shareScreenRecord">
          <el-radio  label="1">{{$t('public.yes')}}</el-radio>
          <el-radio  label="0">{{$t('public.no')}}</el-radio>
        </el-radio-group>
      </el-form-item>
      <!--<span class="help-tips">默认值为否，开启后，系统将自动将网站所有（包含已咨询和未咨询）的网站商机人数、网站访问次数、点击咨询人数、离开人数、商机转化率和离开率进行记录并展示在“访客来源报表中”</span>-->
      <el-form-item class="padding-top">
        <el-button type="primary" class="primary_btn fr" @click="submitForm">{{$t('config.channel.saveSettings')}}</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
  export default {
    name: 'shareScreen',
    data () {
      return {
        shareScreen: '0',
        shareScreenRecord: '0',
        _id: ''
      }
    },
    methods: {
      submitForm () {
        let obj = {
          _id: this._id,
          shareScreen: this.shareScreen,
          shareScreenRecord: this.shareScreenRecord
        }
        this.$store.dispatch('saveGlobalSet', obj).then((rep) => {
          if (rep.success) {
            this.$message.success(this.$t('config.channel.configSuccess'))
          } else {
            this.$message.error(this.$t('qualityCheck.saveFali'))
          }
        })
      }
    },
    beforeMount () {
      this.$store.dispatch('getGlobalSetById', {}).then((resp) => {
        this._id = resp.row._id
        this.shareScreen = resp.row.shareScreen || '0'
        this.shareScreenRecord = resp.row.shareScreenRecord || '0'
      })
    }
  }
</script>
<style lang="stylus" scoped>
  @import "../../../../../assets/common.styl"
  .wrap
    padding 20px 16px
  .help-tips
    color $cf-gray4
  .padding-top
    padding-top 15px
  .form
    width 400px
</style>
